// /​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​
//  * 网盘客户端
//  ​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​/

#include "client_loop.h"




// ​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​
//  * 主函数 - 程序入口
//  * 流程：
//  * 1. 参数检查
//  * 2. 初始化客户端
//  * 3. 运行主循环
//  * 4. 清理资源
//  ​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​*​**​/
int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        printf("Usage: %s <IP> <PORT>\n", argv[0]);
        return 1;
    }

    ClientContext ctx;
    if (init_client(&ctx, argv[1], atoi(argv[2])) != 0)
    {
        printf("client connect error\n");
        return 1;
    }

    int ret = run_client_loop(&ctx);
    close(ctx.sockfd);
    return ret;
}